package stark.app.function.chess;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.stark.chess.endgame.ChessEndGame;
import com.stark.chess.endgame.ChessEndGameManager;

import stark.app.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;

/**
 * Author：daizhongbin on 2024/7/17
 * Email：1027154338@qq.com
 * Desc:
 */
public class ChessEndGameAdapter extends StkProviderMultiAdapter<ChessEndGame> {

    public ChessEndGameAdapter() {
        addItemProvider(new ItemProvider());
    }

    private class ItemProvider extends BaseItemProvider<ChessEndGame> {

        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_chess_end_game;
        }

        @Override
        public void convert(@NonNull BaseViewHolder holder, ChessEndGame endGame) {
            holder.setText(R.id.tvName, endGame.getName());
            int pos = holder.getBindingAdapterPosition();
            ImageView ivLock = holder.getView(R.id.ivLock);
            ivLock.setVisibility(ChessEndGameManager.getInstance().isUnlock(pos) ? View.GONE : View.VISIBLE);
        }
    }

}
